package com.cs.anole.activity;

import android.Manifest;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;

import com.alibaba.android.arouter.launcher.ARouter;
import com.cs.anole.databinding.ActivityMainBinding;
import com.cs.base.BaseActivity;
import com.cs.base.vm.BaseViewModel;
import com.cs.widgetvp.activity.MainActivityVP;
import com.csr.aspectjxmod.annotation.ClickLimit;

public class MainActivity extends BaseActivity<BaseViewModel, ActivityMainBinding> {

    @Override
    protected ActivityMainBinding getViewBinding() {
        return ActivityMainBinding.inflate(LayoutInflater.from(this));
    }

    @Override
    protected void initView() {
        binding.button.setOnClickListener(this);
        startActivity(new Intent(this, MainActivityVP.class));
    }

    @Override
    protected void initData() {
        requestPermissions(1, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }

    @Override
    protected void onPermissions(int request, boolean granted, String... permissions) {
        super.onPermissions(request, granted, permissions);
        if(request == 1 && granted){
        }
    }

    @Override
    protected void showError(Object obj) {

    }

    @ClickLimit
    @Override
    public void onClick(View v) {
        if (v.getId() == binding.button.getId()) {
            startActivity(new Intent(this, MainActivityVP.class));

            // 2. 跳转并携带参数 /demo/ModuleActivity  /demo1/MainUIActivity
            ARouter.getInstance().build("/demo2/MainUIActivity")
                    .withLong("key1", 666L)
                    .withString("key3", "888")
                    .navigation();
        }
    }
}